package com.grape.demo20220803;

import com.grape.demo20220803.config.MasterDataSourceConfiguration;
import com.grape.demo20220803.config.SlaveDataSourceConfiguration;
import com.grape.demo20220803.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.jms.annotation.EnableJms;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/** @noinspection SpringBootApplicationSetup*/
@SpringBootApplication
@EnableJms
//@EnableAutoConfiguration(exclude = DataSourceAutoConfiguration.class)
//@Import({MasterDataSourceConfiguration.class, SlaveDataSourceConfiguration.class})
public class Demo20220803Application {

    public static void main(String[] args) {
        SpringApplication.run(Demo20220803Application.class, args);
    }

    @Bean
    WebMvcConfigurer createWebMvcConfigurer(@Autowired HandlerInterceptor[] handlerInterceptor) {
//        User jack = new User(1, "jack");
//        System.out.println("jack = " + jack);
        return new WebMvcConfigurer() {
            @Override
            public void addResourceHandlers(ResourceHandlerRegistry registry) {
                registry.addResourceHandler("/static/**")
                        .addResourceLocations("classpath:/static/");
            }
        };

    }

}
